<% layout('/layouts/default.html', {title: '', bodyClass: '', libs: ['dataGrid']}){ %>
<style>
    .not-data{
        text-align: center;
        color: grey;
    }
</style>
<div class="content pb0">
    <div >
        <div class="row" style="display: flex">
            <section class="col-md-6 ui-sortable" style="width: 100%;">
                <div class="box box-widget" style="height: 100%;min-height: 200px">
                    <div class="box-body" style="padding-top: 5px">
                        <ul class="todo-list ui-sortable hide" id="taskList"></ul>
                        <div class="not-data" id="notTask">
                            <p>无待办任务~</p>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
<% } %>
<script>
    findTaskData();
    //获取任务列表数据
    function findTaskData() {
        // 待办
        let html = "";
        js.ajaxSubmit({
            dataType: 'json',
            async: true,
            message: '正在获取数据...',
            url: '${ctx}/message/message/findMessageCount',
            callback: function(res){
                if (res.result=='true'){
                    if (res.carCount > 0){
                        html += '<li class="pointer" onclick="toCar(this)">\n' +
                            '    <span class="text2" >您有<span style="font-weight: bold;margin: 0 5px">'+ res.carCount +'</span>条车辆信息待审核，请尽快处理！</span>\n' +
                            '    <small class="label label-danger pull-right"><i class="fa fa-clock-o"></i> 去处理</small>\n' +
                            '</li>';
                    }
                    if (res.merchantCount > 0){
                        html += '<li class="pointer" onclick="toMerchant(this)">\n' +
                            '    <span class="text2" >您有<span style="font-weight: bold;margin: 0 5px">'+ res.merchantCount +'</span>家商户待审核，请尽快处理！</span>\n' +
                            '    <small class="label label-danger pull-right"><i class="fa fa-clock-o"></i> 去处理</small>\n' +
                            '</li>';
                    }
                    if(html!=''){
                        $("#taskList").html(html).removeClass("hide");
                        $("#notTask").addClass("hide");
                    }
                }
            },
        });
    }
    //任务列表具体跳转
    function toMerchant(e) {  // 跳转到商家审核页
        js.addTabPage($('<a class="btnTool" data-tab-id="message_1"></a>'), "商户审核", "${ctx}/merchant/merchant/list?reviewStatus=0", true);
        js.closeCurrentTabPage(function(contentWindow){
            contentWindow.page();
        });
    }
    function toCar(e){   // 跳转到车辆审核页
        js.addTabPage($('<a class="btnTool" data-tab-id="message_1"></a>'), "车辆信息", "${ctx}/car/car/list?carStatus=3", true);
        js.closeCurrentTabPage(function(contentWindow){
            contentWindow.page();
        });
    }
</script>